cap program drop insertrow
program define insertrow

syntax, place(string) row(integer)

qui gen o = _n

qui count
local N1 = r(N)+1
set obs `N1'

if "`place'"=="before" replace o = `row'-0.1 if o==.
if "`place'"=="after"  replace o = `row'+0.1 if o==.

sort o
drop o

end



